<template>
  <div class="home">
     <form action="/">
        <van-search
          v-model="value"
          show-action
          placeholder="请输入搜索关键词"
          @search="onSearch"
          @cancel="onCancel"
        />
      </form>
      <!-- 分类 -->
      <div>
        <van-tabs v-model="active">
          <van-tab title="推荐">
            <!-- 轮播 -->
                <van-swipe :autoplay="3000">
                  <van-swipe-item v-for="(image, index) in images" :key="index">
                    <img v-lazy="image" style="width:100%"/>
                  </van-swipe-item>
                </van-swipe>
            <!-- 商品卡片 -->
                <div v-for="(shop) in shop">
                  <van-card
                    num="2"
                    price="2.00"
                    desc="描述信息"
                    title="商品标题"
                    :thumb="shop.img"
                  >
                    <template #tags>
                      <van-tag plain type="danger">{{shop.price}}</van-tag>
                      
                    </template>
                    <template #footer>
                      <van-button size="mini">按钮</van-button>
                      
                    </template>
                  </van-card>
                  
                 
                </div>
          </van-tab>

          <van-tab title="发布">
              <!-- 发布 -->
              <child></child>
          </van-tab>
          <van-tab title="消息">内容 3</van-tab>
          <van-tab title="我的">内容 4</van-tab>
        </van-tabs>
      </div>

      <!-- 底部 -->
      <div>
        <van-tabbar v-model="active">
        <van-tabbar-item icon="home-o">首页</van-tabbar-item>
        <van-tabbar-item icon="plus">发布</van-tabbar-item>
        <van-tabbar-item icon="chat-o">消息</van-tabbar-item>
        <van-tabbar-item icon="https://b.yzcdn.cn/vant/icon-demo-1126.png">我的</van-tabbar-item>
        
        </van-tabbar>
      </div>
  </div>
</template>

<script>
import { Toast } from 'vant';
import child from '../views/index/index'
export default {
  name: "index",
  components: {
    child:child
  },
  data(){
    return{
      value: '',
      // 底部标签
      active: 'home',
      images: [
        'https://img01.yzcdn.cn/vant/apple-1.jpg',
        'https://img01.yzcdn.cn/vant/apple-2.jpg',
      ],
      shop:[
        {
          img:'https://img01.yzcdn.cn/vant/ipad.jpeg',
          price:20
        },
        {
          img:'https://img01.yzcdn.cn/vant/ipad.jpeg',
          price:10
        },
        {
          img:'https://img01.yzcdn.cn/vant/ipad.jpeg',
          price:10
        }
      ]
    }
  },
  methods:{
    onSearch(val) {
      Toast(val);
    },
    onCancel() {
      Toast('取消');
    },
  }
};
</script>
<style scoped>
  .my-swipe .van-swipe-item {
    color: #fff;
    font-size: 20px;
    line-height: 150px;
    text-align: center;
    background-color: #39a9ed;
  }
</style>
